import java.util.ArrayList;
import java.util.Scanner;

import com.jgx.bean.*;
import com.jgx.dao.*;

public class system509 {
    public static void main(String[] args) {


        ArrayList<User509> users = new ArrayList<>();
        Scanner sc = new Scanner(System.in);

        while (true) {
            System.out.println("==欢迎进入酒店管理系统==");
            System.out.println("1.账户登录");
            System.out.println("2.账户注册");
            System.out.println("==请输入您需要操作的业务：==");
            String command = sc.next();

            switch (command) {
                case "1":
                case "账户登录":
                    LoginMenu(users, sc);
                    break;
                case "2":
                case "账户注册":
                    Register(users, sc);
                    break;
                default:
                    System.out.println("您输入的业务不存在!");
            }
        }

    }

    private static void LoginMenu(ArrayList<User509> users, Scanner sc) {
        System.out.println("请输入您的账号");
        String id = sc.next();
        System.out.println("请输入您的密码");
        String password = sc.next();
        User509 user = getCustomerById(users, id, password);
        if (user != null) {
            System.out.println("登陆成功!");
            Manager();
        }
    }


    private static void Register(ArrayList<User509> users, Scanner sc) {
        System.out.println("请输入您的客户名：");
        String id = sc.next();
        System.out.println("请输入您的密码：");
        String password = sc.next();
        User509 newUser = new User509(id, password);
        users.add(newUser);
        System.out.println("注册成功!");
    }

    private static User509 getCustomerById(ArrayList<User509> users, String id, String password) {
        for (User509 user : users) {
            if (user.getId().equals(id) && user.getPassword().equals(password)) {
                return user;
            }
        }
        return null;
    }

    private static void Manager() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("您要进行哪个方面的信息操作？");
            System.out.println("1.客户信息");
            System.out.println("2.客房信息");
            System.out.println("3.预约早餐");
            System.out.println("4.员工信息");
            System.out.println("5.财务信息");
            System.out.println("6.员工服务信息");
            System.out.println("7.退出");
            String n = sc.next();
            switch (n){
                case "1":
                  cust();
                    break;
                case "2":
                  room();
                    break;
                case "3":
                  breakfast();
                    break;
                case "4":
                  emp();
                    break;
                case "5":
                  fin();
                    break;
                case "6":
                  ser();
                    break;
                case "7":
                  System.exit(0);
                    break;
                default:
                    System.out.println("您输入的业务不存在!");
            }
        }
    }
    private static void cust(){
        CustomerDao509 c = new CustomerDao509();
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入您要进行的操作");
            System.out.println("1.查询客户信息");
            System.out.println("2.删除客户信息");
            System.out.println("3.增加客户信息");
            System.out.println("4.修改客户信息");
            System.out.println("5.退出");
            String a = sc.next();
            switch (a){
                case "1":
                    c.findAll();
                    break;
                case "2":
                    System.out.println("请输入要删除的序号");
                    int id = sc.nextInt();
                    c.deleteByid(id);
                    System.out.println("删除成功!");
                    break;
                case "3":
                    Customer509 customer = new Customer509();
                    System.out.println("请输入要添加的房间号");
                    String room = sc.next();
                    customer.setCroom(room);
                    System.out.println("请输入要添加的姓名");
                    String name = sc.next();
                    customer.setCname(name);
                    System.out.println("请输入要添加的性别");
                    String sex = sc.next();
                    customer.setCsex(sex);
                    System.out.println("请输入要添加的联系方式");
                    String phone = sc.next();
                    customer.setCphone(phone);
                    c.add(customer);
                    System.out.println("添加成功!");

                    break;
                case "4":
                    Customer509 customer1 = new Customer509();
                    System.out.println("请输入要修改的客户号");
                    int idc = sc.nextInt();
                    customer1.setCid(idc);
                    System.out.println("请输入要修改的房间号");
                    String roomc = sc.next();
                    customer1.setCroom(roomc);
                    System.out.println("请输入要修改的姓名");
                    String namec = sc.next();
                    customer1.setCname(namec);
                    System.out.println("请输入要修改的性别");
                    String sexc = sc.next();
                    customer1.setCsex(sexc);
                    System.out.println("请输入要修改的联系方式");
                    String phonec = sc.next();
                    customer1.setCphone(phonec);
                    c.update(customer1);
                    System.out.println("修改成功!");
                    break;
                case "5":
                        System.exit(0);
                        break;
                default:
                    System.out.println("您输入的操作不存在!");
            }
        }

    }
    private static void room(){
        RoomDao502 r = new RoomDao502();
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入您要进行的操作");
            System.out.println("1.查询客房信息");
            System.out.println("2.删除客房信息");
            System.out.println("3.增加客房信息");
            System.out.println("4.修改客房信息");
            System.out.println("5.退出");
            String a = sc.next();
            switch (a){
                case "1":
                    r.findAll();
                    break;
                case "2":
                    System.out.println("请输入要删除的编号");
                    int id = sc.nextInt();
                    r.deleteByid(id);
                    System.out.println("删除成功!");
                    break;
                case "3":
                    Room502 room = new Room502();
                    System.out.println("请输入要添加的客户号");
                    int idd = sc.nextInt();
                    room.setCustomerID(idd);
                    System.out.println("请输入要添加的房间类型");
                    String type = sc.next();
                    room.setRoomType(type);
                    System.out.println("请输入要添加的房间状态");
                    String status = sc.next();
                    room.setStatus(status);
                    System.out.println("请输入要添加的价格");
                    String price = sc.next();
                    room.setPrice(price);
                    System.out.println("请输入要添加的时间");
                    String time = sc.next();
                    room.setTime(time);
                    r.add(room);
                    System.out.println("添加成功!");

                    break;
                case "4":
                    Room502 room1 = new Room502();
                    System.out.println("请输入要修改的房间号");
                    int roomid = sc.nextInt();
                    room1.setRoomID(roomid);
                    System.out.println("请输入要修改的客户号");
                    int iddd = sc.nextInt();
                    room1.setCustomerID(iddd);
                    System.out.println("请输入要修改的房间类型");
                    String typee = sc.next();
                    room1.setRoomType(typee);
                    System.out.println("请输入要修改的房间状态");
                    String statuss = sc.next();
                    room1.setStatus(statuss);
                    System.out.println("请输入要修改的价格");
                    String prices = sc.next();
                    room1.setPrice(prices);
                    System.out.println("请输入要修改的时间");
                    String timee = sc.next();
                    room1.setTime(timee);
                    r.update(room1);
                    System.out.println("修改成功!");
                    break;
                case "5":
                    System.exit(0);
                    break;
                default:
                    System.out.println("您输入的操作不存在!");
            }
        }
    }
    private static void breakfast(){
        BreakfastDao503 b = new BreakfastDao503();
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入您要进行的操作");
            System.out.println("1.查询预约早餐信息");
            System.out.println("2.删除预约早餐信息");
            System.out.println("3.增加预约早餐信息");
            System.out.println("4.修改预约早餐信息");
            System.out.println("5.退出");
            String a = sc.next();
            switch (a){
                case "1":
                    b.findAll();
                    break;
                case "2":
                    System.out.println("请输入要删除的编号");
                    int id = sc.nextInt();
                    b.deleteByid(id);
                    System.out.println("删除成功!");
                    break;
                case "3":
                    Breakfast503 breakfast = new Breakfast503();
                    System.out.println("请输入要添加的客户号");
                    int idd = sc.nextInt();
                    breakfast.setBcid(idd);
                    System.out.println("请输入要添加的身份证号");
                    String type = sc.next();
                    breakfast.setbIDcard(type);
                    System.out.println("请输入要添加的早餐类型");
                    String status = sc.next();
                    breakfast.setBreakfastType(status);
                    System.out.println("请输入要添加的支付价格");
                    String price = sc.next();
                    breakfast.setbPayPrice(price);
                    System.out.println("请输入要添加的预约时间");
                    String time = sc.next();
                    breakfast.setBtime(time);
                    b.add(breakfast);
                    System.out.println("添加成功!");

                    break;
                case "4":
                    Breakfast503 breakfast1 = new Breakfast503();
                    System.out.println("请输入要修改的预约号");
                    int iddd = sc.nextInt();
                    breakfast1.setBid(iddd);
                    System.out.println("请输入要修改的客户号");
                    int iidd = sc.nextInt();
                    breakfast1.setBcid(iidd);
                    System.out.println("请输入要修改的身份证号");
                    String typee = sc.next();
                    breakfast1.setbIDcard(typee);
                    System.out.println("请输入要修改的早餐类型");
                    String statuss = sc.next();
                    breakfast1.setBreakfastType(statuss);
                    System.out.println("请输入要修改的支付价格");
                    String prices = sc.next();
                    breakfast1.setbPayPrice(prices);
                    System.out.println("请输入要修改的预约时间");
                    String timee = sc.next();
                    breakfast1.setBtime(timee);
                    b.update(breakfast1);
                    System.out.println("修改成功!");
                    break;
                case "5":
                    System.exit(0);
                    break;
                default:
                    System.out.println("您输入的操作不存在!");
            }
        }
    }
    private static void emp(){
        employDao502 e = new employDao502();
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入您要进行的操作");
            System.out.println("1.查询员工信息");
            System.out.println("2.删除员工信息");
            System.out.println("3.增加员工信息");
            System.out.println("4.修改员工信息");
            System.out.println("5.退出");
            String a = sc.next();
            switch (a){
                case "1":
                    e.findAll();
                    break;
                case "2":
                    System.out.println("请输入要删除的编号");
                    int id = sc.nextInt();
                    e.deleteByid(id);
                    System.out.println("删除成功!");
                    break;
                case "3":
                    employee502 em = new employee502();
                    System.out.println("请输入要添加的房间号");
                    int idd = sc.nextInt();
                    em.setRoomNumber(idd);
                    System.out.println("请输入要添加的姓名");
                    String type = sc.next();
                    em.setName(type);
                    System.out.println("请输入要添加的性别");
                    String status = sc.next();
                    em.setGender(status);
                    System.out.println("请输入要添加的联系方式");
                    String price = sc.next();
                    em.setContact(price);
                    System.out.println("请输入要添加的房间清洁时间");
                    String time = sc.next();
                    em.setCleantime(time);
                    e.add(em);
                    System.out.println("添加成功!");

                    break;
                case "4":
                    employee502 emp1 = new employee502();
                    System.out.println("请输入要修改的客户号");
                    int iddd = sc.nextInt();
                    emp1.setEmployeeNumber(iddd);
                    System.out.println("请输入要修改的房间号");
                    int iidd = sc.nextInt();
                    emp1.setRoomNumber(iidd);
                    System.out.println("请输入要修改的姓名");
                    String typee = sc.next();
                    emp1.setName(typee);
                    System.out.println("请输入要修改的性别");
                    String statuss = sc.next();
                    emp1.setGender(statuss);
                    System.out.println("请输入要修改的联系方式");
                    String prices = sc.next();
                    emp1.setContact(prices);
                    System.out.println("请输入要修改的清洁时间");
                    String timee = sc.next();
                    emp1.setCleantime(timee);
                    e.update(emp1);
                    System.out.println("修改成功!");
                    break;
                case "5":
                    System.exit(0);
                    break;
                default:
                    System.out.println("您输入的操作不存在!");
            }
        }
    }
    private static void fin() {
        FinanceDao509 f = new FinanceDao509();
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入您要进行的操作");
            System.out.println("1.查询财务信息");
            System.out.println("2.删除财务信息");
            System.out.println("3.增加财务信息");
            System.out.println("4.修改财务信息");
            System.out.println("5.退出");
            String a = sc.next();
            switch (a) {
                case "1":
                    f.findAll();
                    break;
                case "2":
                    System.out.println("请输入要删除的序号");
                    int id = sc.nextInt();
                    f.deleteByid(id);
                    System.out.println("删除成功!");
                    break;
                case "3":
                    Finance509 finance = new Finance509();
                    System.out.println("请输入要添加的客户号");
                    int room = sc.nextInt();
                    finance.setCustomerID(room);
                    System.out.println("请输入要添加的房间总价格");
                    String name = sc.next();
                    finance.setTrp(name);
                    System.out.println("请输入要添加的预约早餐总价格");
                    String sex = sc.next();
                    finance.setTbp(sex);
                    f.add(finance);
                    System.out.println("添加成功!");

                    break;
                case "4":
                    Finance509 finance1 = new Finance509();
                    System.out.println("请输入要修改的财务编号");
                    int idc = sc.nextInt();
                    finance1.setFinanceID(idc);
                    System.out.println("请输入要修改的客户号");
                    int roomc = sc.nextInt();
                    finance1.setCustomerID(roomc);
                    System.out.println("请输入要修改的房间总价格");
                    String namec = sc.next();
                    finance1.setTrp(namec);
                    System.out.println("请输入要修改的预约早餐总价格");
                    String sexc = sc.next();
                    finance1.setTbp(sexc);

                    f.update(finance1);
                    System.out.println("修改成功!");
                    break;
                case "5":
                    System.exit(0);
                    break;
                default:
                    System.out.println("您输入的操作不存在!");
            }
        }

    }
    private static void ser() {
        serviceDao503 s = new serviceDao503();
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入您要进行的操作");
            System.out.println("1.查询员工服务信息");
            System.out.println("2.删除员工服务信息");
            System.out.println("3.增加员工服务信息");
            System.out.println("4.修改员工服务信息");
            System.out.println("5.退出");
            String a = sc.next();
            switch (a) {
                case "1":
                    s.findAll();
                    break;
                case "2":
                    System.out.println("请输入要删除的员工号");
                    int id = sc.nextInt();
                    s.deleteByid(id);
                    System.out.println("删除成功!");
                    break;
                case "3":
                    service503 service = new service503();
                    System.out.println("请输入要添加的房间号");
                    int room = sc.nextInt();
                    service.setRoomid(room);
                    System.out.println("请输入要添加的服务时间");
                    String name = sc.next();
                    service.setServicetTime(name);
                    System.out.println("请输入要添加的服务员工姓名");
                    String sex = sc.next();
                    service.setYgName(sex);
                    s.add(service);
                    System.out.println("添加成功!");

                    break;
                case "4":
                    service503 service1 = new service503();
                    System.out.println("请输入要修改的员工编号");
                    int idc = sc.nextInt();
                    service1.setId(idc);
                    System.out.println("请输入要修改的房间号");
                    int roomc = sc.nextInt();
                    service1.setRoomid(roomc);
                    System.out.println("请输入要修改的服务时间");
                    String namec = sc.next();
                    service1.setServicetTime(namec);
                    System.out.println("请输入要修改的服务员工姓名");
                    String sexc = sc.next();
                    service1.setYgName(sexc);

                    s.update(service1);
                    System.out.println("修改成功!");
                    break;
                case "5":
                    System.exit(0);
                    break;
                default:
                    System.out.println("您输入的操作不存在!");
            }
        }

    }
    }